package edu.ucsd.db.bassarisk.query.binding;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import edu.ucsd.db.bassarisk.columndef.DataColumnDefinition;
import edu.ucsd.db.bassarisk.query.binding.Bindings.Binding;

public class BindingTuple {
  private final List<Binding> bindings;
  private final List<List<DataColumnDefinition>> candiateColumns;
  
  public BindingTuple() {
    this.bindings = new ArrayList<Binding>();
    this.candiateColumns = new ArrayList<List<DataColumnDefinition>>();
  }
  
  public BindingTuple(Collection<Binding> bindings) {
    this.bindings = new ArrayList<Binding>();
    this.candiateColumns = new ArrayList<List<DataColumnDefinition>>();
    this.addAllFields(bindings);
  }
  
  public void addField(Binding binding) {
    this.bindings.add(binding);
    this.candiateColumns.add(new ArrayList<DataColumnDefinition>());
  }
  
  public void addAllFields(Collection<Binding> bindings) {
    for (Binding b : bindings) {
      this.addField(b);
    }
  }
  
  public Iterable<Binding> bindings() {
    return this.bindings;
  }

  public int size() {
    return this.bindings.size();
  }

  public boolean contains(Binding target) {
    return this.bindings.contains(target);
  }
}
